<template>
	<view class="">
		<view style="height: 24rpx;"></view>
		<view style="width: 686rpx;margin-left: 32rpx;">
			<view class="schedule-title">
				<text>{{detail.title}}</text>
			</view>
			<view class="schedule-content">
				<image src="../../../../static/phone/phone_schedul_time.png" style="width: 32rpx;height: 32rpx;"></image>
				<text style="color: #666666;margin-left: 4rpx;">{{detail.beginTimes}}
				<text style="margin-left: 5rpx;margin-right: 5rpx;">至</text>
				{{detail.endTimes}}</text>
			</view>
			<view class="schedule-content">
				<image src="../../../../static/phone/phone_schedul_people.png" style="width: 32rpx;height: 32rpx;"></image>
				<text style="color: #333333;margin-left: 4rpx;">{{detail.joinType.desc}}</text>
			</view>
			<view class="schedule-content">
				<image src="../../../../static/phone/phone_schedul_ling.png" style="width: 32rpx;height: 32rpx;"></image>
				<text style="color: #333333;margin-left: 4rpx;">{{detail.tips}}</text>
			</view>
			
			<view class="schedule-content">
				<text style="color: #333333;">所属案件</text>
				<text style="color: #2DA9C5;margin-left: 10rpx;" @click="checkCase()">查看</text>
			</view>
		</view>
		
		<view class="view-bottom" v-if="role!='0'">
			<view class="view-bottom-s">
				<view class="view-bottom-sl" @click="deleteIt()">
					删除
				</view>
				<view class="view-bottom-sr" @click="clickEdit()">
					编辑
				</view>
			</view>
			
		</view>
	</view>
	
</template>

<script>
	let app = ''
	export default{
		data(){
			return{
				id:'',
				role:'',
				roleUrl:'',
				detail:null,
			}
		},
		onLoad(options) {
			let _this = this
			app = getApp()
			_this.id = options.id
			_this.role = app.globalData.role
			_this.roleUrl =  _this.$roleUrl({tab:_this.role})
			
			
		},
		onShow() {
			this.getDetail()
		},
		mounted() {
		
		},
		methods:{
			
			async getDetail(){
				let _this = this
				const res = await _this.$myRequest({
					url:`/${_this.roleUrl}/caseTodo/${_this.id}`,
					method: 'GET'
				})
				console.log('日程详情',res)
				if(res.data.code==200){
					let data =  res.data.data
					let tipsTimes = data.tipsTimes
					let tips = ''
					for (var i = 0; i < tipsTimes.length; i++) {
						tips = tips+tipsTimes[i]['desc']+','
					}
					if(tips.length>1){
						tips = tips.substring(0,tips.length-1)
					}
					
					if(tips==''){
						tips = '无提醒'
					}
					data.tips = tips
					
					data.beginTimes = data.beginTime.substring(0,16)
					data.endTimes = data.endTime.substring(0,16)
					_this.detail = data
				}
			},
			
			
			/**
			 * 点击了编辑
			 */
			clickEdit(){
				let detail = JSON.stringify(this.detail)
				uni.navigateTo({
					url:'./addSchedule?tag=edit&detail='+detail
				})
			},
			
			/**
			 * 点击查看所属案件
			 */
			checkCase(){
				let caseId = this.detail.caseId
				uni.navigateTo({
					url:'../caseDetail/caseDetail?id='+caseId
				})
			},
			/**
			 * 删除
			 */
			async deleteIt(){
				let _this = this
				let params = {
					ids:_this.id
				}
				const res = await _this.$myRequest({
					url:`/${_this.roleUrl}/caseTodo`,
					method: 'DELETE',
					data:params
				})
				console.log('删除',res)
				if(res.data.code==200){
					uni.showToast({
						title:'删除成功!',
						icon:"success",
						duration:1500
					})
					uni.setStorageSync("schedele",'delete')
					setTimeout(function() {
						uni.navigateBack({
							delta:-1
						})
					}, 1500);
				}
			},
		}
	}
</script>

<style>
	page{
		background-color: #ffffff;
	}
</style>
<style scoped lang="scss">
	.schedule-title{
		font-size: 32rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #333333;
	}
	.schedule-content{
		display: flex;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		margin-top: 20rpx;
	}
	.view-bottom{
		position: fixed;
		width: 100%;
		bottom: 0;
		background-color: #ffffff;
		padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
	}
	.view-bottom-s{
		height: 108rpx;
		display: flex;
		align-items: center;
	}
	.view-bottom-sl{
		width: 260rpx;
		height: 88rpx;
		border-radius: 44rpx;
		border: 1px solid #2DA9C5;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #2DA9C5;
		margin-left: 32rpx;
	}
	.view-bottom-sr{
		width: 394rpx;
		height: 88rpx;
		background: #2DA9C5;
		border-radius: 58rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #ffffff;
		margin-left: 32rpx;
	}
</style>